<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript" src="./ajax.js"></script>
    <script type="text/javascript">
    window.onload = function(){
        var btn1 = document.getElementById('btn1');
        btn1.onclick = function(){
            ajax('./10-1.php','get','username=李四&password=123','text',function(data){
                var div1 = document.getElementById('info1');
                div1.innerHTML = data;
            });
        }

        var btn2 = document.getElementById('btn2');
        btn2.onclick = function(){
            ajax('./10-2.php','post','username=张三&password=123456','json',function(data){
                var div2 = document.getElementById('info2');
                // div2.innerHTML = data;
                div2.innerHTML = data.username + "=====" + data.password;
            });
        }
    }
    </script>
</head>
<body>
    <div id="info1"></div>
    <input type="button" value="点击1" id="btn1">
    <div id="info2"></div>
    <input type="button" value="点击2" id="btn2">
</body>
</html>